#include "./../../../include/online/Reactor/TcpServer.h"

TcpServer::TcpServer(const string& ip,unsigned int port)
:_acceptor(ip,port)
,_loop(_acceptor)
{

}
TcpServer::~TcpServer()
{

}

// 服务器的启动与停止
void TcpServer::start()
{
    _acceptor.ready();
    _loop.loop();
}
void TcpServer::stop()
{
    _loop.unloop();
}

// 传所有的事件（回调函数）
void TcpServer::setAllCallback(Callback&& cb1,Callback&& cb2,Callback&& cb3)
{
    _loop.setNewConnectionCallback(std::move(cb1));
    _loop.setMessageCallback(std::move(cb2));
    _loop.setCloseCallback(std::move(cb3));
}